package com.weilan.blog.picture.fallback;

import com.weilan.blog.base.holder.RequestHolder;
import com.weilan.blog.picture.feign.PictureFeignClient;
import com.weilan.blog.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 图片服务降级兜底方法【当服务不可用时会触发】
 * @author: 孙 峰
 * @time: 2020/10/20 14:12
 */
@Slf4j
@Component
public class PictureFeignFallback implements PictureFeignClient {
    @Override
    public String getPicture(String fileIds, String code) {
        HttpServletRequest request = RequestHolder.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        log.error("图片服务出现异常，服务降级返回，请求路径: {}", requestURL);
        return ResultUtil.errorWithMessage("获取图片服务降级返回");

    }
}
